package com.yhally.seata.storage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yhally.seata.storage.dao.StorageDao;
import com.yhally.seata.storage.domain.Storage;
import com.yhally.seata.storage.service.StorageService;
import com.yhally.seata.storage.tcc.StorageTccAction;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 *
 * @author wangyu
 * @version 1.0
 * @date 2022/5/6 23:00
 */
@Service
@RequiredArgsConstructor(onConstructor = @_(@Autowired))
public class StorageServiceImpl extends ServiceImpl<StorageDao, Storage> implements StorageService {

    private final StorageDao storageDao;
    private final StorageTccAction storageTccAction;
    @Override
    public void decrease(Long productId, Integer count) {
        storageDao.decrease(productId, count);
    }

    @Override
    public void decreaseByTcc(Long productId, Integer count) {
        storageTccAction.decrease(null,productId,count);
    }
}
